<?php
/**
 * Description of Cron
 *
 * @author andres
 */
class Emms_Cron
{
    const MODE_MAINTENANCE = 'Maintenance';
    const MODE_NORMAL = 'Normal';
    
    public $db;
    public $conf;
    public $date;
    public $time;
    public $datetime;
    
    public function __construct() 
    {
        $this->conf = Zend_Registry::get('HT_Config');
        $this->db = Zend_Db_Table_Abstract::getDefaultAdapter();
        $this->date = date('Y-m-d');
        $this->time = date('H:i:s');
        $this->datetime = date('Y-m-d H:i:s');
    }
    
    public function setMode($mode,$script,$comments="")
    {
        switch($mode) {
            case self::MODE_MAINTENANCE: break;
            case self::MODE_NORMAL: break;
            default:
                throw new Exception('Invalid cron_job mode request from script ' . $script);
        }
        $cronJobs = new Zend_Db_Table(array('name' => 'cron_jobs', 'primary' => 'Id'));
        $cronJobs->insert(array('Date' => date('Y-m-d'), 'Time' => date('H:i:s'), 
            'Mode' => $mode, 'Script' => $script, 'Comments' => $comments));
    }
}

?>
